@extends('admin.container')

@section('c-head')
    <script type="text/javascript">
        var PAGE_DATA = {
            REST_API: {
                get_goods_list: "{{route('admin.goods.manage.index')}}", //商品列表

                secendCategory: "{{route('goods.primary-category.category')}}", //二级分类
                del_multi_goods: "{{route('admin.goods.manage.batch-remove')}}", //批量删除商品
                remove_on_multi_goods: "{{route('admin.goods.manage.shelve')}}", // 批量上架
                remove_off_multi_goods: "{{route('admin.goods.manage.un-shelve')}}", // 批量下架
            },
            // 商品属性
            goods_property: [
                {code: "2", text: "自由集散"},
                {code: "1", text: "供采分销"},
            ],
            // 状态
            state: [
                {code: "1", text: "出售中"},
                {code: "2", text: "下架"},
            ],
            // 分类
            classify: $.parseJSON('{!! \App\Http\Controllers\GoodsCategoryGetterController::getSpecial() !!}'),
        };
    </script>
@stop

@section('c-body')
    <div class="comm-title">
        <span class="title-msg">商品管理</span>
    </div>
    <div class="comm-body">
        <div id="top-tab" class="am-btn-group" style="margin-top: 22px;">
            <button type="button" class="am-btn am-btn-primary am-btn-sm" id="allgoods" code="0">
                <span style="width:90px;display:block;">所有商品</span>
            </button>
            <button type="button" class="am-btn am-btn-default am-btn-sm" id="goodswithdraw" code="1">
                <span style="width:90px;display:block;">违规下架</span>
            </button>
        </div>
        <div class="shopadmin-screen">
            <div class="shopadmin-screen-main">
                <div class="screen-main-top">
                    <span>商品名称：</span>
                    <input type="text" id="good_name">
                    <span class="ml25">店铺名称：</span>
                    <input type="text" id="store_name">
                    <span class="ml25">品牌名称：</span>
                    <input type="text" id="brand_name">
                </div>
                <div class="screen-main-top mt10">
                    <span>商品属性：</span>
                    <select id="good_property">

                    </select>
                    <span class="ml25">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</span>
                    <select id="good_state">
                        <option value="1">出售中</option>
                        <option value="0">违规下架</option>
                    </select>
                    <span class="ml25">分&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类：</span>
                    <select id="classify_0" name="items">
                        <option></option>
                    </select>
                    <select id="classify_1" style="display: none">
                        <option></option>
                    </select>
                    <button id="search-btn" type="button" class="am-btn am-btn-success am-btn-xs">搜索</button>
                </div>
            </div>
        </div>

        <div>
            <!-- 表单列表 -->
            <div id="tab-body-0" class="sel-tab-body" style="display: block;">
                <table class="am-table am-table-striped am-table-hover am-table-centered brand-manage-tbl shopadmin-list">
                    <thead>
                    <tr>
                        <th style="width:5%">
                            <span style="visibility:hidden;">1</span>
                        </th>
                        <th>商品名称</th>
                        <th>店铺名称</th>
                        <th>所属分类</th>
                        <th>品牌</th>
                        <th>商品属性</th>
                        <th>批发价</th>
                        <th>库存</th>
                        <th>状态</th>
                        <th style="width:15%">操作</th>
                    </tr>
                    </thead>
                    <tbody class="shopadmin-list-body" id="goods-context-0">
                    </tbody>
                </table>
                <div class="tool-bar-bottom clearfix">
                    <div class="unit" style="width: 30px">
                        <input id="sel-all-chk-0" type="checkbox" class="mid" style="position: relative; top:13px;" />
                    </div>
                    <div class="unit">
                        <label for="sel-all-chk-0" style="cursor:pointer;font-weight:300;">
                            全选
                        </label>
                    </div>

                    <div class="unit" style="width: auto;">

                        <button id="remove-off-multi" type="button"
                                class="am-btn am-btn-success am-btn-xs "
                                style="position: relative;float:left;top:5px;">
                            违规下架
                        </button>

                        <button id="del-multi-btn-0" type="button"
                                class="am-btn am-btn-default am-btn-xs ml10"
                                style="position: relative;float:left;top:5px;">
                            删除
                        </button>
                    </div>
                </div>
                <div id="comm-paging-0" class="admin-paging" current-page="1"></div>
            </div>
            <div id="tab-body-1" class="sel-tab-body" style="display: none">
                <table class="am-table am-table-striped am-table-hover am-table-centered brand-manage-tbl shopadmin-list">
                    <thead>
                    <tr>
                        <th style="width:5%">
                            <span style="visibility:hidden;">1</span>
                        </th>
                        <th>商品名称</th>
                        <th>店铺名称</th>
                        <th>所属分类</th>
                        <th>品牌</th>
                        <th>商品属性</th>
                        <th>批发价</th>
                        <th>库存</th>
                        <th>状态</th>
                        <th style="width:15%">操作</th>
                    </tr>
                    </thead>
                    <tbody class="shopadmin-list-body" id="goods-context-1">
                    </tbody>
                </table>
                <div class="tool-bar-bottom clearfix">
                    <div class="unit" style="width: 30px">
                        <input id="sel-all-chk-1" type="checkbox" class="mid" style="position: relative; top:13px;" />
                    </div>
                    <div class="unit">
                        <label for="sel-all-chk-1" style="cursor:pointer;font-weight:300;">
                            全选
                        </label>
                    </div>
                    <div class="unit" style="width: auto;">
                        <button id="remove-on-multi" type="button" class="am-btn am-btn-success am-btn-xs " style="position: relative;float:left;top:5px;">
                            恢复上架
                        </button>
                        <button id="del-multi-btn-1" type="button" class="am-btn am-btn-default am-btn-xs ml10" style="position: relative;float:left;top:5px;">
                            删除
                        </button>
                    </div>
                </div>
                <div id="comm-paging-1" class="admin-paging" current-page="1"></div>
            </div>
        </div>
    </div>
    <script type="text/template" id="goods-list-templ">
        <%_.each(obj, function(item){%>
        <tr>
            <td class="sel-chk">
                <input type="checkbox" id="<%=item.id%>" />
                <img src="<%=item.imgurl%>"></td>
            <td>
                <span><%=item.goodsname%></span>
            </td>
            <td>
                <span style="width: 96px;"><%=item.storename%></span>
            </td>
            <td>
                <%=item.classify%>
            </td>
            <td style="max-width: 150px">
                <%=item.brand%>
            </td>
            <td style="max-width: 80px">
                <%=item.goodsproperty%>
            </td>
            <td style="max-width: 72px">
                ￥
                <%=item.price%>
            </td>
            <td style="max-width: 70px">
                <%=item.stock%>
            </td>
            <td style="width: 80px;max-width: 80px">
                <%=item.state %>
            </td>
            <td style="width:15%">

                <div class="operate-btns-2 clearfix" style="width: auto;">
                    <a id="" type="button" class="edit-brand-btn am-btn am-btn-primary am-btn-xs"
                       href="<%=item.detail_href%>" style="float:left;">
                        查看
                    </a>
                    <%if(item.operate=="0"){%>
                    <button id="" type="button" class="am-btn am-btn-default am-btn-xs withdraw-btn"
                            style="float:left; margin-left: 10px;" href="<%=item.update_href%>" code="<%=item.id%>">
                        违规下架
                    </button>
                    <%}else if (item.operate=="1"){%>
                    <button id="" type="button" class="am-btn am-btn-success am-btn-xs grounding-btn"
                            style="float:left; margin-left: 10px;" href="<%=item.update_href%>" code="<%=item.id%>">
                        恢复上架
                    </button>
                    <% } else {%>
                    <button id="" type="button" class="am-btn am-btn-success am-btn-xs "
                            style="float:left; margin-left: 10px; visibility:hidden;">
                        隐藏
                    </button>
                    <% }%>
                </div>
            </td>
        </tr>
        <%})%>
    </script>
    <script src="/assets/b2b/admin/js/libs/jquery.paging.min.js"></script>
    <script src="/assets/b2b/admin/js/libs/dialog-min.js"></script>
    <script src="/assets/b2b/admin/js/pages/07-08.js"></script>
@stop